/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */
#pragma once

#include <Config.h>
#include <lib3d/model/Model.h>
#include <lib3d/model/ModelInHardware.h>
#include "Model.h"
#include "Factory.h"
#include <animate/Envelope.h>
#include <animate/Soul.h>
#include <vector>
#include <CompilerFeatures.h>

namespace liba {
namespace lib3d {
namespace node {

class Trace :
	public Node,
	public HardwareDependentObject<hard::Manager, hard::VertexBuffer>
{
	NODE_DEFINITION(Trace)
public:
	static const Atom node_name;
	// Nodes
	static const Atom shader_name;

	Trace( const Atom & name, Node * parent );
	virtual ~Trace();

	virtual void RenderToList( hard::Hardware * hardware, hard::RenderList * render_list ) LIBA_OVERRIDE;
	virtual animate::Node * FindAnimateNode( const Atom & name, bool recursion ) LIBA_OVERRIDE;
protected:
	virtual void on_add_hardware(hard::Manager::hardware_type * ha) LIBA_OVERRIDE;
	virtual bool on_attribute( xml::Provider * prov, const std::string & name, const std::string & value ) LIBA_OVERRIDE;
	virtual bool on_node( xml::Provider * prov, const std::string & name ) LIBA_OVERRIDE;
	virtual bool on_end_node( xml::Provider * prov ) LIBA_OVERRIDE;
	void LifeCycle(time_float delta_time);
private:
	material::Shader shader;

	animate::EnvelopeTCB<Vector> envelope_tcb;

	int update_buffer(hard::VertexBuffer * vb);
};


} // namespace node
} // namespace lib3d
} // namespace liba
using namespace liba;

